package com.zwy.common.utils;

import com.zwy.common.exception.ResultCode;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseResult<T> {
    private Integer code;
    private String message;
    private T data;

    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(ResultCode.SUCCESS.getCode(),
                                  ResultCode.SUCCESS.getMessage(), 
                                  data);
    }

    public static <T> ResponseResult<T> success(String message, T data) {
        return new ResponseResult<>(ResultCode.SUCCESS.getCode(), message, data);
    }

    public static <T> ResponseResult<T> error(ResultCode resultCode) {
        return new ResponseResult<>(resultCode.getCode(), 
                                  resultCode.getMessage(), 
                                  null);
    }

    public static <T> ResponseResult<T> error(Integer code, String message) {
        return new ResponseResult<>(code, message, null);
    }

    public static <T> ResponseResult<T> error(String message) {
        return new ResponseResult<>(ResultCode.FAILED.getCode(), message, null);
    }
}